import React, {Component} from 'react';
import { List, Input, Button} from 'antd';

import {URL} from "../../../src/constant/Constant";

export default class Patent extends Component{
    constructor(props){
        super(props);
        this.state = {
            patentData : '',
            inputValue: ''
        }
    }

    componentDidMount = () =>{
        fetch(URL.urlRoot+"/documentlist",{
            method:"Get",
            headers: {
                "Content-Type": "application/json",
                'Authorization': window.localStorage.authorization,
            }
        }).then((res) =>{
            return res.json()
        }).then((res) => {
            this.setState({
                PatentData: res,
            });
        })
    }
    handleInputValue = (e) => {
        this.setState({
            inputValue: e.target.value
        })
    }
    // 查询方法
    handleBtn = () => {
        const inputValue = this.state.inputValue;
    }

    render(){
        return(
            <div>
                <h1 style = {{textAlign: 'center'}}>专利</h1>
                <div>
                    <Input placeholder = '请输入关键字' value = {this.state.inputValue} 
                        onChange = {this.handleInputValue } 
                        style = {{width:'300px',marginRight:'10px',marginBottom:20}} />
                    <Button onClick = {this.handleBtn} type = 'primary' >查询</Button>
                </div>
                <div>
                <List
                    size="small"
                    bordered
                    dataSource={this.state.PatentData}
                    pagination={{
                        pageSize: 4,
                    }}
                    renderItem={item => (<List.Item>
                    <a href = {"http://duodao.chende.top" + item.downloadPath}>{item.title}</a>
                    </List.Item>)}
                    />  
                </div>
            </div>
        )
    }
}